from django.db import models


# Create your models here.

class Student(models.Model):
    GENDER_CHOICES = (
        (1, 'female'),
        (0, 'male')
    )
    sname = models.CharField(max_length=10, verbose_name='学生名字')
    sgender = models.SmallIntegerField(choices=GENDER_CHOICES, default=0, verbose_name='性别')
    sage = models.IntegerField(verbose_name='年龄')

    class Meta:
        db_table = 'tb_stu'

    def __str__(self):
        return self.sname


class Subject(models.Model):
    sub_name = models.CharField(max_length=20, verbose_name='课程名字')
    sub_scores = models.IntegerField(default=0, verbose_name='成绩')
    sub_time = models.DateField(verbose_name='考试时间')
    sub_stu = models.ForeignKey(Student, verbose_name='学生')

    class Meta:
        db_table = 'tb_sub'

    def __str__(self):
        return self.sub_name
